package com.zimi.controller;

import com.zimi.model.WfWorkflowInstance;
import com.zimi.service.WfWorkflowApplicationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Auther: lmc
 * @Date: 2019/3/29 10:20
 * @Description:
 */

@Api("流程管理")
@RestController
@RequestMapping("wf/workflow/application")
public class WfWorkflowApplicationApi {
    @Autowired
    WfWorkflowApplicationService wfWorkflowApplicationService;

    @PostMapping("getFormDesignPrivilege")
    @ApiOperation("获取表单")
    public Map getFormDesignPrivilege(WfWorkflowInstance wfWorkflowInstance) {
        Map returnMap = new HashMap();
        returnMap.put("data", wfWorkflowApplicationService.getInstanceHtml(wfWorkflowInstance, 0));
        returnMap.put("OK", "OK");
        returnMap.put("code", 200);

        return returnMap;
    }

    @PostMapping("getFormView")
    @ApiOperation("获取表单")
    public Map getFormView(int baseTaskId) {
        Map returnMap = new HashMap();
        returnMap.put("data", wfWorkflowApplicationService.getInstanceHtml(null, baseTaskId));
        returnMap.put("OK", "OK");
        returnMap.put("code", 200);

        return returnMap;
    }

    /**
     * 打开流程实例页面
     *
     * @return
     */
    @PostMapping("getDefaultValue")
    @ApiOperation("获取表单默认值")
    public Map getDefaultValue(String valueCode) {
        Map returnMap = new HashMap();
        returnMap.put("data", wfWorkflowApplicationService.getDefaultValue(valueCode));
        returnMap.put("OK", "OK");
        return returnMap;
    }
}
